<template>
  <div>
    <van-dropdown-menu>
      <van-dropdown-item
        v-model="value1"
        :options="option1"
        title="综合"
        disabled
      />

      <van-dropdown-item
        v-model="value2"
        :options="option2"
        title="价格"
        @change="priceChange"
      />
      <van-dropdown-item
        v-model="categoryVal"
        :options="filterCategory"
        title="分类"
        @change="categoryChangeSearch"
      />
    </van-dropdown-menu>

    <!-- 搜索提示 -->
    <van-empty
      v-if="goodsList.length === 0"
      image="search"
      description="没有搜索到相关商品"
    />
    <products v-else :goodsList="goodsList" />
  </div>
</template>

<script>
import products from "@/components/Products";
export default {
  props: ["goodsList", "filterCategory"],
  // updated() {
  //   this.filterCategory.map((item) => {
  //     if (item.checked) {
  //       this.category = item.value;
  //     }
  //   });
  // },
  data() {
    return {
      //   list: [1, 2, 3, 4, 5],
      categoryVal: 0,
      value1: 0,
      value2: "asc",
      option1: [
        { text: "全部", value: 0 },
        { text: "居家", value: 1 },
      ],
      option2: [
         { text: "价格由低到高", value: "asc" },
        { text: "价格由高到低", value: "desc" },
      ],
    };
  },
  methods: {
    categoryChangeSearch(id) {
      this.$emit("categoryChangeSearch", id);
    },
    priceChange(val) {
      // console.log(val);
      this.$emit("priceChangeSearch", val);
    },
  },
  components: {
    products,
  },
};
</script>
 
<style lang = "less" scoped>
</style>